<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <input type="text" v-model="info">
    <input type="text" v-model="info1">
    <input type="button" value="加" v-on:click="f(1)">
    <input type="button" value="减" v-on:click="f(2)">
    <input type="button" value="乘" v-on:click="f(3)">
    <input type="button" value="除" v-on:click="f(4)">
    <h1>{{info2}}</h1>
</div>
<script src="js/vue.min.js"></script>
<script>
    let v = new Vue({
        el: "body>div",
        data: {
            info: "",
            info1: "",
            info2: ""
        },
        methods: {
            f(num) {
                if(isNaN(v.info)||isNaN(v.info1)){
                    v.info2="输入错误";
                    v.info1="";
                    v.info="";
                }else {
                switch (num) {
                    case 1:
                        v.info2 = parseFloat(v.info) + parseFloat(v.info1);
                        break;
                    case 2:
                        v.info2 = parseFloat(v.info) - parseFloat(v.info1);
                        break;
                    case 3:
                        v.info2 = parseFloat(v.info) * parseFloat(v.info1);
                        break;
                    case 4:
                        v.info2 = parseFloat(v.info) / parseFloat(v.info1);
                        break;
                }}
            }
        }
    })
</script>
</body>
</html>